package com.lbb.springboot.util;

import com.lbb.springboot.entity.vo.InstallVo;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.UUID;

public class Test4 {

    //生成安装证明图片

    public static void main(String[] args) throws Exception {

        String orderId="200";
        String filePath="D:\\xcx\\install\\";
//        String filePath = "C:\\Users\\CangMaoMao\\IdeaProjects\\xlulbb\\src\\main\\java\\com\\lbb\\img/";

//        String page="pagesIndex/pages/red-packet/red-packet";
//        String page="pages/index/index";
//        String wsQRcode = getWXACodeUnlimit(filePath,orderId,page, 280, true, null, true);
//        System.out.println("wxaCodeUnlimit:" + wsQRcode);

        //        // 获取类所在项目路径，获取方式有多种
//        String address = Main.class.getResource("/").getPath();
//        String address = "C:\\Users\\CangMaoMao\\Desktop\\shareImg-master\\src\\";
        // 头像
//        String avastar = filePath + "install.jpg";
        // 二维码
//        String qrcode = filePath + wsQRcode;
        // 二维码识别图
//        String point = filePath + "point.png";
        // 背景图片
        String background = filePath + "install.jpg";

        InstallVo installVo=new InstallVo();
        installVo.setCompanyName("广州市健福运输有限公司");
        installVo.setPlate("粤AX2121");
        installVo.setColor("黄色");
        installVo.setYear("2018");
        installVo.setMonth("12");
        installVo.setDay("01");
        installVo.setSerialNumber("014045530937");
        installVo.setSimlbbd("1440045530937 ");
        // 1. 通过背景图片构建 BufferedImage
        BufferedImage zoomPicture = ImageIO.read(new File(background));
//        BufferedImage roundedImage = ImageIO.read(new File(avastar));
        // 2. 头像裁剪成圆形
//        BufferedImage roundedImage = SharedImageUtils.createRoundedImage(avastar, SharedImageUtils.AVATAR_SIZE);
        // 3. 合并头像，昵称
        BufferedImage mergeImage = InstallImageUtils.mergePicture(zoomPicture,  installVo);
        // 4. 合并二维码及二维码识别图
//        mergeImage = SharedImageUtils.mergeQrcode(mergeImage, qrcode, null);
        // 5. 生成分享图
        String fileName = DateUtil.getNowDate() + UUID.randomUUID().toString().substring(0, 8) +"result.jpg";
        ImageIO.write(mergeImage, "jpg", new File(filePath + fileName));

    }
}
